package lab01;

/**
 * Created by lenovo on 2017/9/29.
 */

import java.util.Scanner;

public class Test08 {
    public static void main(String args[]) {
        int number = (int) (Math.random() * 100) + 1;//获取一个随机数
        int i = 0;
        while (true) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入一个整数");
            int x = sc.nextInt();
            i += 1;//记录输入的次数
            if (x > number) {
                System.out.println("猜大了");
            } else if (x < number) {
                System.out.println("猜小了");
            } else if (x == number) {
                System.out.println("恭喜您，猜对啦！！！");
                System.out.println("您一共尝试了" + i + "次");
            }
        }
    }
}
